#pragma once
#include "MyEffect.h"

class Border : public MyEffect
{
private:
	int _miniShapesDiameter;	

public:
	Border(void)
	{
		_miniShapesDiameter = 0;
	}

	Border(int diameter)
	{
		_miniShapesDiameter = diameter;
	}

	~Border(void)
	{
	}

	Border(int x, int y, int width, int height, char stroke[], int strokeWidth, char fill[])
	{
	}

	void SetMiniShapesDiameter(int diameter)
	{
		_miniShapesDiameter = diameter;
	}

	string GetName()
	{
		return "Border";
	}

	void DrawEffect(MyGraphics* g)
	{
		// Tim 8 vi tri can de ve 8 mini shapes
		int radious = _miniShapesDiameter / 2;

		MyPoint pos = _shape->GetPosition();
		int width = _shape->GetWidth();
		int height = _shape->GetHeight();

		MyPoint pOut1, pOut2, pOut3, pOut4;		// Toa do 4 diem bien (goc HCN)
		MyPoint pIn1, pIn2, pIn3, pIn4;			// Toa do 4 diem o giua (goc HCN)
		
		pOut1.x = pos.x - radious;
		pOut1.y = pos.y - radious;

		pOut2.x = pos.x + width - radious;
		pOut2.y = pos.y - radious;

		pOut3.x = pos.x + width - radious;
		pOut3.y = pos.y + height - radious;

		pOut4.x = pos.x - radious;
		pOut4.y = pos.y + height - radious;

		pIn1.x = pos.x + width / 2 - radious;
		pIn1.y = pos.y - radious;

		pIn2.x = pos.x + width - radious;
		pIn2.y = pos.y + height / 2 - radious;

		pIn3.x = pos.x + width / 2 - radious;
		pIn3.y = pos.y + height - radious;

		pIn4.x = pos.x - radious;
		pIn4.y = pos.y + height / 2 - radious;

		// Ve 4 hinh tron cho ngoai bien
		g->FillEllipse(_color, pOut1.x, pOut1.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillEllipse(_color, pOut2.x, pOut2.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillEllipse(_color, pOut3.x, pOut3.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillEllipse(_color, pOut4.x, pOut4.y, _miniShapesDiameter, _miniShapesDiameter);

		// Ve 4 hinh vuong cho o giua
		g->FillRectangle(_color, pIn1.x, pIn1.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillRectangle(_color, pIn2.x, pIn2.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillRectangle(_color, pIn3.x, pIn3.y, _miniShapesDiameter, _miniShapesDiameter);
		g->FillRectangle(_color, pIn4.x, pIn4.y, _miniShapesDiameter, _miniShapesDiameter);
	}

	void Draw(MyGraphics* g)
	{
		if (_shape != 0)
		{
			// Ve doi tuong duoc phu hieu ung truoc
			_shape->Draw(g);

			// Ve hieu ung sau
			DrawEffect(g);
		}
	}
};

